<?php
include "../include/global.php";
include "../include/admin_check.php";
$xtpl = new XTemplate ("slideshowWrite.htm");
include "setting.php";
//
include "../include/function.php";
$xtpl->assign("left_panel", left_panel());
$xtpl->assign("header_panel", header_panel());
$xtpl->assign("footer_panel", footer_panel());
include "setting.php";

// ++ lang
if($lang=='v'){
	$xtpl->assign('type_vietnamese', 'onkeyup="initTyper(this)"');
}
$xtpl->assign("title", Slideshow);
$xtpl->assign("lbl_search", Search);
$xtpl->assign("lbl_no", No);
$xtpl->assign("lbl_country", Country);
$xtpl->assign("lbl_tab", Tab);
$xtpl->assign("lbl_name", Name);
$xtpl->assign("lbl_link", Link);
$xtpl->assign("lbl_image", Image);
$xtpl->assign("lbl_position", Position);
$xtpl->assign("lbl_active", Active);
$xtpl->assign("lbl_save", Save);
$xtpl->assign("lbl_save_add", SaveAdd);
$xtpl->assign("lbl_cancel", Cancel);
// -- lang

$ID=intval($_GET['ID']);
if($ID){
	$sql="select * from ".pre_table."logo where logo_id='$ID'";
	$row=recordset($sql);
	$country_id=$row['country_id'];
	$tab=$row['tab'];
	$logo_name=$row['logo_name'];
	$logo_link=$row['logo_link'];
	$old_logo_image=$row['logo_image'];	
	
	$logo_position=$row['logo_position'];	
	$logo_isactive=$row['logo_isactive'];	
	
	if($row[logo_isactive]==1) $ChkActive = "checked";			
	
	$xtpl->assign("logo_name", $logo_name);
	$xtpl->assign("logo_link", $logo_link);
	$xtpl->assign("old_logo_image", $old_logo_image);
	$xtpl->assign("logo_position", $logo_position);
	$xtpl->assign("logo_isactive", $logo_isactive);
	$xtpl->assign("ChkActive", $ChkActive);
	$xtpl->assign("id", $ID);
	
	$xtpl->assign("type", "EDIT");	
}else{
	// ++ set position
	$stsql = "SELECT logo_id from ".pre_table."logo WHERE lang='".$lang."'";
	$rssql = execSQL($stsql);
	$numrec=mysql_num_rows($rssql);
	$logo_position=$numrec+1;
	$xtpl->assign("logo_position", $logo_position);
	// -- set position
	
	$xtpl->assign("type", "ADD");	
	$xtpl->assign("ChkActive", "checked");
}

$xtpl->assign("cbo_country", cbo_country($country_id));
$xtpl->assign("cbo_tab", cbo_tab($tab));

// ++ image
if($old_logo_image)
{
	$has_image='<img src='.$path.$old_logo_image.' width="50" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:del_image('.$ID.')">'.Delete.'</a>';
}
$xtpl->assign("has_image", $has_image);


//////////////////////////////////////
$xtpl->parse("MAIN");
eval("?".">".$xtpl->text("MAIN"));
?>